//
//  ItemsTableViewCell.m
//  MyMainDemo
//
//  Created by FM123 on 2018/1/30.
//  Copyright © 2018年 LiMin. All rights reserved.
//

#import "ItemsTableViewCell.h"
#import "ItemsViewController.h"

@interface ItemsTableViewCell()

@property (nonatomic, strong) ItemsViewController *oneVC;
@property (nonatomic, strong) ItemsViewController *twoVC;
//@property (nonatomic, strong) ItemsViewController *threeVC;

@end

@implementation ItemsTableViewCell
{
    CustomSegmentView *_RCSegView;
}
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    self.opaque=YES;
        
    self.layer.borderColor=UIColorFromRGB(0xffffff).CGColor;
        //    [self addSubview:[self setPageViewControllers]];
        self.oneVC=[[ItemsViewController alloc]init];
        
        self.twoVC=[[ItemsViewController alloc]init];
        
        NSArray *controllers=@[self.oneVC,self.twoVC];
        NSArray *titleArray =@[@"page1",@"page2"];
        
        self.RCSegView=[[CustomSegmentView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-StatusBarAndNavBarHeight-TabbarHeight) controllers:controllers titleArray:titleArray ParentController:self.superview.viewController lineWidth:WIDTH/5 lineHeight:3. andSelect:0];
        self.RCSegView.backgroundColor=[UIColor whiteColor];
        [self addSubview: self.RCSegView];
    }
    
    return self;
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
//    if (scrollView == self.scrollView) {
//        if (self.delegate &&
//            [self.delegate respondsToSelector:@selector(mmtdOptionalScrollViewDidEndDecelerating:)]) {
//            [self.delegate mmtdOptionalScrollViewDidEndDecelerating:scrollView];
//        }
//    }
}
-(UIView *)setPageViewControllers
{
    if (!_RCSegView) {
        ItemsViewController *sceneVC=[[ItemsViewController alloc]init];
        
        ItemsViewController *sceneVC1=[[ItemsViewController alloc]init];
        
        NSArray *controllers=@[sceneVC,sceneVC1];
        NSArray *titleArray =@[@"page1",@"page2"];
        
        CustomSegmentView * rcs=[[CustomSegmentView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) controllers:controllers titleArray:titleArray ParentController:self.superview.viewController lineWidth:WIDTH/5 lineHeight:3. andSelect:0];
        rcs.backgroundColor=[UIColor whiteColor];
        //        rcs.delegate=self;
        _RCSegView = rcs;
    }
    return _RCSegView;
}

- (void)setObjectCanScroll:(BOOL)objectCanScroll {
    _objectCanScroll = objectCanScroll;
    
    self.oneVC.vcCanScroll = objectCanScroll;
    self.twoVC.vcCanScroll = objectCanScroll;
//    self.threeVC.vcCanScroll = objectCanScroll;
    
    if (!objectCanScroll) {
        [self.oneVC.myTableView setContentOffset:CGPointZero animated:NO];
        [self.twoVC.myTableView setContentOffset:CGPointZero animated:NO];
//        [self.threeVC.tableView setContentOffset:CGPointZero animated:NO];
    }
}

@end
